//1、定义路由表
import Home from "../views/Home.vue";
import Hello from "../views/Hello.vue";
import {createMemoryHistory, createRouter, createWebHashHistory} from "vue-router";
import User from "../views/user/User.vue";
import UserProfile from "../views/user/UserProfile.vue";
import UserPosts from "../views/user/UserPosts.vue";

const routes = [
    { path: '/', component: Home },
    { path: '/hello', component: Hello },
    { path: '/haha/:id', component: ()=>import("../views/Haha.vue")},
    {
        path: '/user/:id',
        component: User,
        name: "User",
        children: [
            {
                // /user/007/profile
                path: 'profile',
                name: 'Profile',
                component: UserProfile

            },
            {
                path: 'posts',
                component: UserPosts
            }
        ]
    }

]
//2、创建路由器
const router = createRouter({
    history: createWebHashHistory(),
    routes: routes,
});
//3、导出路由器
export default router;
//4、vue实例使用路由器